package com.ymatou.iapi.optrade.parameter.enums;

import java.util.Map;

/**
 * 风控状态枚举值
 */
public enum RiskControlStatusEnum {
	/**
	 * 风控未通过，订单已取消处理
	 */
	RejectedAndCanceled(-1),
	/**
	 * 未知状态
	 */
	Unknown(0),
	/**
	 * 未检测，初始状态
	 */
	Init(1),
	/**
	 * 风控检测通过
	 */
	Pass(2),
	/**
	 * 检测未通过，需要立即进行风控处理(取消订单)
	 */
	Rejected(3),
	/**
	 * 风控检测失败 滞留，需后续处理(滞留)
	 */
	Auditing(4);

	private int code;

	private RiskControlStatusEnum(int code) {
		this.code = code;
	}

	public int getCode() {
		return code;
	}

	public static RiskControlStatusEnum getRiskControlStatus(
			Map<String, String> paramExt) {
		if (paramExt == null) {
			return RiskControlStatusEnum.Unknown;
		}
		String status = paramExt.get("Status");
		if (status == null) {
			return RiskControlStatusEnum.Unknown;
		}
		switch (status.toLowerCase()) {
			case "init" :
				return RiskControlStatusEnum.Init;
			case "pass" :
				return RiskControlStatusEnum.Pass;
			default :
				return RiskControlStatusEnum.Unknown;

		}
	}
}
